package com.ruoyi.web.controller.monitor;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.BusWaterIntegrationmonitordata;
import com.ruoyi.monitor.service.IBusWaterIntegrationmonitordataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手工断面监测数据（月）Controller
 * 
 * @author maliang
 * @date 2025-08-16
 */
@RestController
@RequestMapping("/monitor/integrationmonitordata")
public class BusWaterIntegrationmonitordataController extends BaseController
{
    @Autowired
    private IBusWaterIntegrationmonitordataService busWaterIntegrationmonitordataService;

    /**
     * 查询手工断面监测数据（月）列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:integrationmonitordata:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterIntegrationmonitordata busWaterIntegrationmonitordata)
    {
        startPage();
        List<BusWaterIntegrationmonitordata> list = busWaterIntegrationmonitordataService.selectBusWaterIntegrationmonitordataList(busWaterIntegrationmonitordata);
        return getDataTable(list);
    }

    /**
     * 导出手工断面监测数据（月）列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:integrationmonitordata:export')")
    @Log(title = "手工断面监测数据（月）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterIntegrationmonitordata busWaterIntegrationmonitordata)
    {
        List<BusWaterIntegrationmonitordata> list = busWaterIntegrationmonitordataService.selectBusWaterIntegrationmonitordataList(busWaterIntegrationmonitordata);
        ExcelUtil<BusWaterIntegrationmonitordata> util = new ExcelUtil<BusWaterIntegrationmonitordata>(BusWaterIntegrationmonitordata.class);
        util.exportExcel(response, list, "手工断面监测数据（月）数据");
    }

    /**
     * 获取手工断面监测数据（月）详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:integrationmonitordata:query')")
    @GetMapping(value = "/{segmentid}")
    public AjaxResult getInfo(@PathVariable("segmentid") String segmentid)
    {
        return success(busWaterIntegrationmonitordataService.selectBusWaterIntegrationmonitordataBySegmentid(segmentid));
    }

    /**
     * 新增手工断面监测数据（月）
     */
    @PreAuthorize("@ss.hasPermi('monitor:integrationmonitordata:add')")
    @Log(title = "手工断面监测数据（月）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusWaterIntegrationmonitordata busWaterIntegrationmonitordata)
    {
        return toAjax(busWaterIntegrationmonitordataService.insertBusWaterIntegrationmonitordata(busWaterIntegrationmonitordata));
    }

    /**
     * 修改手工断面监测数据（月）
     */
    @PreAuthorize("@ss.hasPermi('monitor:integrationmonitordata:edit')")
    @Log(title = "手工断面监测数据（月）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusWaterIntegrationmonitordata busWaterIntegrationmonitordata)
    {
        return toAjax(busWaterIntegrationmonitordataService.updateBusWaterIntegrationmonitordata(busWaterIntegrationmonitordata));
    }

    /**
     * 删除手工断面监测数据（月）
     */
    @PreAuthorize("@ss.hasPermi('monitor:integrationmonitordata:remove')")
    @Log(title = "手工断面监测数据（月）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{segmentids}")
    public AjaxResult remove(@PathVariable String[] segmentids)
    {
        return toAjax(busWaterIntegrationmonitordataService.deleteBusWaterIntegrationmonitordataBySegmentids(segmentids));
    }

    /**
     * 主要污染物占比（月）
     * @return
     */
    @GetMapping("/monthPollutantsPropor")
    public AjaxResult monthPollutantsPropor(String startTime,String endTime,String countyCode,String riverId){
        return AjaxResult.success(busWaterIntegrationmonitordataService.monthPollutantsPropor(startTime,endTime,countyCode,riverId));
    }

    /**
     * 主要污染物占比(年)
     * @return
     */
    @GetMapping("/yearPollutantsPropor")
    public AjaxResult dayPollutantsPropor(String year,String countyCode,String riverId){
        return AjaxResult.success(busWaterIntegrationmonitordataService.yearPollutantsPropor(year,countyCode,riverId));
    }
}
